package top.wshape1.shiziapi.search.service;

import top.wshape1.shiziapi.common.domain.ProjectSearch;
import top.wshape1.shiziapi.search.domain.ProjectSearchPage;

import java.io.IOException;
import java.util.Date;
import java.util.List;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2023-11-26
 */

public interface ProjectSearchService {

    /**
     * 保存项目
     *
     * @param project
     * @throws IOException
     */
    void save(ProjectSearch project) throws IOException;

    /**
     * 删除项目
     *
     * @param id
     * @throws IOException
     */
    void remove(Long id) throws IOException;

    /**
     * 设置项目点赞数
     *
     * @param id
     * @param count
     * @throws IOException
     */
    void setLike(Long id, Long count) throws IOException;

    /**
     * 项目点赞加减
     *
     * @param id
     * @param plusOrReduce 'plus' or 'reduce'
     * @throws IOException
     */
    void plusOrReduceLike(Long id, String plusOrReduce, Date updateTime) throws IOException;

    /**
     * 项目浏览量+1
     * @param id
     */
    void plusRead(Long id, Date updateTime) throws IOException;

    /**
     * 获取热门项目
     *
     * @param page
     * @return
     * @throws IOException
     */
    ProjectSearchPage getHotProjects(int page) throws IOException;

    /**
     * 搜索项目
     *
     * @param page
     * @param keyword
     * @return
     * @throws IOException
     */
    ProjectSearchPage searchProject(int page, String keyword) throws IOException;

    /**
     * 搜索一定时间内的项目
     *
     * @param startTime
     * @param endTime
     * @return
     * @throws IOException
     */
//    List<ProjectSearch> getProjectBetweenUpdateTime(int page, int size, Date startTime, Date endTime) throws IOException;
    List<ProjectSearch> getProjectBetweenUpdateTime(Date startTime, Date endTime) throws IOException;

    /**
     * 搜索项目总数
     *
     * @param keyword
     * @return
     * @throws IOException
     */
    long countProject(String keyword) throws IOException;

    ProjectSearch getByProjectId(Long projectId) throws IOException;
}
